#ifndef USERVER_H
#define USERVER_H

#ifdef __cplusplus
   extern "C" {
#endif
#include "uthash.h"

typedef int (*svr_parse_cb)(void *, int );
typedef void (*svr_msg_cb)(unsigned short , char * );

typedef struct _Usvr_Incoming
{
	int ui_dev;
	int ui_fd;
	UT_hash_handle hh;
}Usvr_Incoming;

typedef struct _Usvr_Info
{
	int us_symbol;
    const char *path;
	int svr_fd;
    int svr_dev;
	Usvr_Incoming *list;
	svr_parse_cb uc_cb;
    svr_msg_cb uc_mcb;
	UT_hash_handle hh;
}Usvr_Info;


void usvr_multicast(Usvr_Info *pinfo, int dev, unsigned char *package, int len);
void usvr_append_incomingsocket(Usvr_Incoming **pplist, int sockfd);
void usvr_remove_incomingsocket(Usvr_Incoming **pplist, int sockfd);
void usvr_refresh_incominginfo(Usvr_Incoming **pplist, int sockfd, int dev);
void *usvr_connected_handle(void *pv);
void *usvr_accept_handle(void *p);
int usvr_create(const char *path, int dev, svr_parse_cb cb);
int usvr_create2(const char *path, int dev, svr_parse_cb cb, svr_msg_cb mcb);

#ifdef __cplusplus
	}
#endif

#endif	/*USERVER_H*/